package net;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class UdpSendDemo01 {
    public static void main(String[] args) {
        try {

            DatagramSocket datagramSocket = new DatagramSocket();

            // 要发送的数据
            String content = "这是一个测试6666666666";
            DatagramPacket datagramPacket = new DatagramPacket(content.getBytes(), content.getBytes().length
            , InetAddress.getByName("192.168.1.201"), 8888);

            // 发送数据
            datagramSocket.send(datagramPacket);

            // 关闭资源
            datagramSocket.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
